/**
 * @file    drv_timer.h
 * @author  yhy
 * @brief   芯必达IM94x系列芯片, timer抽象层
 * @version 1.01
 * @date    2025-07-09
 *
 * @copyright Copyright (c) 2025
 *
 * @details
 * Change Logs:
 * Date           Author       Notes
 * 2025-07-09     yhy          the first version V1.00
 * 2025-07-11     yhy          所有函数和变量名修改为snf_开头 V1.01
 *
 */
#ifndef __DRV_TIMER_H__
#define __DRV_TIMER_H__

#include "common_config.h"

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#define TIMER_HW_INSTANCE_MAXSIZE (4) /*!< Timer硬件实例最大数量 */

typedef void (*timer_callback_f)(void);

/**
 * @brief TIMER实例
 *
 */
typedef enum
{
    TIMER_INSTANCE_TIMER0 = 0U,
    TIMER_INSTANCE_TIMER1 = 1U,
    TIMER_INSTANCE_TIMER2 = 2U,
    TIMER_INSTANCE_TIMER3 = 3U,
    TIMER_INSTANCE_MAX
} snf_timer_instance_e;

/**
 * @brief TIMER配置参数, 时钟源30MHz
 *
 */
typedef struct
{
    snf_timer_instance_e instance;      /*!< Timer实例 */
    uint8_t              prescaler;     /*!< Timer时钟预分频, 0 ~ 255, 实际分频 + 1 */
    uint32_t             compare_value; /*!< Timer计数值 */
    timer_callback_f     callback;      /*!< Timer回调函数 */
} snf_timer_config_t;

result_e snf_drv_timer_init(const snf_timer_config_t *timer_config);
result_e snf_drv_timer_start(snf_timer_instance_e instance);
result_e snf_drv_timer_stop(snf_timer_instance_e instance);

#endif
